package com.pactera.controller;

import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.cc.model.FileUpload;
import com.cc.service.FileUploadService;

/**
 * @author CongWT
 * @date 2017年12月28日 上午10:56:15
 * @read "触点体系"
 */
@Controller
@RequestMapping("/teest")
public class TeestController {

	private static Logger logger = LoggerFactory.getLogger(TeestController.class);


	@Autowired
	private FileUploadService fileUploadService;
	
	/**
	 * @author CongWT
	 * @date 2018年1月2日 上午11:43:46
	 * @read "所有无需初始化的页面在此依参数返回"
	 * @param objdata传递的数据
	 * @param name定位需要的页面
	 * @return
	 */

	@RequestMapping("/all/{name}")
	@RequiresPermissions("touchpoint:TALL")
	public ModelAndView getPlanPage(String objdata, @PathVariable String name) {

		ModelAndView mv = new ModelAndView();

		logger.info("getPage name={} return", name);
		return mv;
	}


	/**
	 * @author CongWT
	 * @date 2018年1月2日 上午10:07:53
	 * @param id
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/by/{id}")
	@RequiresPermissions("FileUpload:TALL")
	public String selectFileUploadBy(@PathVariable String id) {
		FileUpload fileUpload = null;
		if (StringUtils.isNotEmpty(id)) {
			logger.info("selectFileUploadBy TO fileUploadService.selectByPrimaryKey(id):" + id);
			fileUpload = this.fileUploadService.selectByPrimaryKey(Integer.valueOf(id));
			logger.info("selectFileUploadBy return fileUpload=" + fileUpload == null ? "null"
					: fileUpload.getId() + "");
		}
		return JSON.toJSONString(fileUpload);
	}

	
}
